<?php
// 整站生成JSON规范数组
function get_json_data($data, $status = 'succ', $desc = 'OK')
{
	header_no_cache();
	return json_encode(array('status' => $status, 'desc' => $desc, 'data' => $data));
}

/**
 *生成规范的JSON
 *
 * @param string	 $comments
 * @return string
 */
function get_js_data($data, $status = 'succ', $desc = 'OK', $jsvar = '_js_data')
{
	header_no_cache();
	header("Content-Type:application/javascript");
	if ($_js_i = _g('_js_i'))
	{
		return $jsvar .'['. _g('_js_i') .'] = ' . json_encode(array('status' => $status, 'desc' => $desc, 'data' => $data)) . ';';
	}
	else
	{
		return  'var ' . $jsvar .' = ' . json_encode(array('status' => $status, 'desc' => $desc, 'data' => $data)) . ';';
	}
}

//JSON转数组
function json_to_array($data){
	$arr=array();
	$arr = json_decode($data);
	return $data;
}
?>